home *** CD-ROM | disk | FTP | other *** search
/ AMIGA-CD 2 / Amiga-CD - Volume 2.iso / ungepackte_daten / 1995 / 6 / 02 / c++-kurs / dirtree.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-01  |  1.8 KB  |  78 lines

  1.  
  2. // $VER: DirTree.h 2.00 (24-Apr-95) ©CM 1995
  3.  
  4.  
  5. #include <utility/hooks.h>
  6. #include <exec/memory.h>
  7. #include <dos/dos.h>
  8. #include <dos/exall.h>
  9. #include <exec/types.h>
  10. #include <stdlib.h>
  11. #include <stdio.h>
  12. #include <string.h>
  13.  
  14. //extern "C"  {
  15. #include <clib/alib_protos.h>
  16. #include <pragma/dos_lib.h>
  17. #include <pragma/exec_lib.h>
  18. #include <pragma/utility_lib.h>
  19. //}
  20.  
  21. #define ed_downerB    ed_Size
  22. //#define REC_DELETE_AFTER_PARENTDIR 1
  23.  
  24. #define REC_ERROR 1
  25. #define REC_FILEFOUND 2
  26. #define REC_DIRECTORYNAME 3
  27. #define REC_INIT 4
  28. #define REC_FINISHED 5
  29.  
  30. struct BlockList {
  31.     struct BlockList *next;
  32.     struct ExAllData *upper;         // für Rekursion
  33.     ULONG BufSize;
  34.     BPTR lock;
  35.     struct ExAllData *ExAllData;  // Wird während der Sortierung verändert
  36.     struct ExAllData *ExAllDCopy; // Deshalb Kopie
  37. };
  38.  
  39. class DirTree  {
  40.     int                     option;
  41.     struct BlockList*    root;    
  42.     char*                    pattern;
  43.     char*                    directory;
  44. protected:
  45.     struct BlockList *SearchRek(char *, char *, struct ExAllData *, int);
  46.     void                     DeleteDirBlock(struct BlockList *);
  47.     void                     DeleteAllBlocks(struct BlockList*, struct ExAllData *,int);
  48.     struct BlockList *ReadDir(BPTR lock);
  49.     //virtual void HookMethod(DirTree::rectype, char*, ExAllData*) {}
  50.     virtual void Error(const char*) = 0;
  51.     virtual void FileFound(const ExAllData*) = 0;
  52.     virtual void DirChanged(const char*) = 0;
  53.     virtual void Init() {}
  54.     virtual void Finish() {}
  55.     int running;
  56. public:
  57.     DirTree(char *Dir, char *Pattern = "#?")  {
  58.         directory = Dir;
  59.         pattern = new char[strlen(Pattern)*2+10];
  60.         ParsePatternNoCase(Pattern, pattern,strlen(Pattern)*2+10);
  61.     }
  62.     void ReadRecursively()  {
  63.         Init();
  64.         root = SearchRek(directory, pattern, NULL, 0);    
  65.         Finish();
  66.     };
  67.     ~DirTree()  {
  68.         if(root) DeleteAllBlocks(root, NULL, 0);
  69.         delete[] pattern;
  70.     };
  71.     // int SetOptions(int options);
  72. };
  73.  
  74.  
  75.  
  76.  
  77.  
  78.